package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TIncomeLog;
import com.ruoyi.business.service.ITIncomeLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收益流水Controller
 * 
 * @author laoguo
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/business/income")
public class TIncomeLogController extends BaseController
{
    @Autowired
    private ITIncomeLogService tIncomeLogService;

    /**
     * 查询收益流水列表
     */
    @PreAuthorize("@ss.hasPermi('business:income:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIncomeLog tIncomeLog)
    {
        startPage();
        List<TIncomeLog> list = tIncomeLogService.selectTIncomeLogList(tIncomeLog);
        return getDataTable(list);
    }

    /**
     * 导出收益流水列表
     */
    @PreAuthorize("@ss.hasPermi('business:income:export')")
    @Log(title = "收益流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TIncomeLog tIncomeLog)
    {
        List<TIncomeLog> list = tIncomeLogService.selectTIncomeLogList(tIncomeLog);
        ExcelUtil<TIncomeLog> util = new ExcelUtil<TIncomeLog>(TIncomeLog.class);
        util.exportExcel(response, list, "收益流水数据");
    }

    /**
     * 获取收益流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:income:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(tIncomeLogService.selectTIncomeLogByLogId(logId));
    }

    /**
     * 新增收益流水
     */
    @PreAuthorize("@ss.hasPermi('business:income:add')")
    @Log(title = "收益流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TIncomeLog tIncomeLog)
    {
        return toAjax(tIncomeLogService.insertTIncomeLog(tIncomeLog));
    }

    /**
     * 修改收益流水
     */
    @PreAuthorize("@ss.hasPermi('business:income:edit')")
    @Log(title = "收益流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TIncomeLog tIncomeLog)
    {
        return toAjax(tIncomeLogService.updateTIncomeLog(tIncomeLog));
    }

    /**
     * 删除收益流水
     */
    @PreAuthorize("@ss.hasPermi('business:income:remove')")
    @Log(title = "收益流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(tIncomeLogService.deleteTIncomeLogByLogIds(logIds));
    }
}
